package com.qingchunlin.springaop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
//@Component
@Order(3)
public class TestAspect1 {

    @Before("execution(* com.qingchunlin.springaop.controller.*.*(..))")
    public void doBefore(){
        log.info("执行TestAspect1 Before...");
    }

    @After("execution(* com.qingchunlin.springaop.controller.*.*(..))")
    public void doAfter() {
        log.info("执行TestAspect1 After...");
    }


    @AfterReturning("execution(* com.qingchunlin.springaop.controller.*.*(..))")
    public void doAfterReturning() {
        log.info("执行TestAspect1 AfterReturning...");
    }

    @AfterThrowing("execution(* com.qingchunlin.springaop.controller.*.*(..))")
    public void doAfterThrowing() {
        log.info("执行TestAspect1 AfterThrowing...");
    }

    @Around("execution(* com.qingchunlin.springaop.controller.*.*(..))")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("执行TestAspect1 Around 前...");
        Object result = proceedingJoinPoint.proceed();
        log.info("执行TestAspect1 Around 后...");
        return result;
    }
}
